package com.example.administrator.yunniuusedcar.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.model.mode_benn.RanCarXiangQingBean;

import java.util.List;

/**
 * Created by Administrator on 2018/1/4 0004.
 */

public class GuiGeAttrAdapter extends BaseAdapter {
    Context context;

    public GuiGeAttrAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        if(spec_value==null)
            return 0;
        return spec_value.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.fragment_guige_attr_item,null);

        TextView attr_name = (TextView)v.findViewById(R.id.attr_name);
        attr_name.setText(spec_value.get(i).name);

        TextView attr_value = (TextView)v.findViewById(R.id.attr_value);
        attr_value.setText(spec_value.get(i).value);
        return v;
    }

    List<RanCarXiangQingBean.Data.Spec.SpecValue> spec_value;
    public void setData(List<RanCarXiangQingBean.Data.Spec.SpecValue> spec_value) {
        this.spec_value = spec_value;
        notifyDataSetChanged();
    }
}
